Create Vocabulary and Taxonomy and How to Use Them in Views (Drupal 10)

Drupal CMS

Drupal CMS

Create Vocabulary and Taxonomy and How to Use Them in Views (Drupal 10)

Introduction

In Drupal, Taxonomy is a powerful core system used to classify, organize, and relate content. Taxonomy helps site builders group content using terms like Categories, Tags, Topics, Departments, etc. These terms are stored inside Vocabularies.

When taxonomy is combined with Views, it becomes extremely powerful. You can filter content, create category-wise listings, build dynamic pages, sliders, and much more.

This article explains:

  • What taxonomy and vocabulary are
  • How to create them in Drupal 10
  • How to use taxonomy in content types
  • How to use taxonomy in Views

 

What is Taxonomy in Drupal?

Taxonomy is a content classification system. It allows you to assign structured labels (terms) to content.

Examples:

  • Blog categories: News, Technology, Education
  • Tags: PHP, Drupal, JavaScript
  • Departments: HR, IT, Finance

Each group of terms is stored inside a Vocabulary.

 

What is a Vocabulary?

A Vocabulary is a container that holds related taxonomy terms.

Example:

Vocabulary name: Categories

  • News
  • Sports
  • Technology

Vocabulary name: Tags

  • Drupal
  • PHP
  • CSS

 

Step 1: Create a Vocabulary in Drupal 10

  1. Go to Structure → Taxonomy
  2. Click Add vocabulary
  3. Fill the details:
    • Name: Categories
    • Description: Content categories for articles
  4. Click Save

The vocabulary is now created.

 

Step 2: Add Terms to Vocabulary

  1. Click List terms next to the vocabulary
  2. Click Add term
  3. Enter term name (example: News)
  4. Save

Repeat this step to add multiple terms.

 

Step 3: Attach Vocabulary to a Content Type

To use taxonomy, you must add it as a field to a content type.

  1. Go to Structure → Content types
  2. Click Manage fields for your content type (e.g., Article)
  3. Click Add field
  4. Select Reference → Taxonomy term
  5. Field label: Category
  6. Click Save and continue

Field Settings:

  • Reference type: Taxonomy term
  • Vocabulary: Categories
  • Allowed number of values: 1 or Unlimited

Save the field.

Now editors can select a category while creating content.

 

Step 4: Create Content Using Taxonomy

  1. Go to Content → Add content → Article
  2. Enter title and body
  3. Select a Category term
  4. Save

Create multiple contents with different categories.

 

Step 5: Use Taxonomy in Views

Now we will use taxonomy to filter and display content using Views.

Example: Create Category-wise Article Listing

  1. Go to Structure → Views → Add view
  2. View name: Articles by Category
  3. Show: Content
  4. Content type: Article
  5. Create a page
  6. Save and edit

 

Step 6: Add Fields in View

Add the following fields:

  • Content: Title
  • Content: Body (optional)
  • Content: Category (taxonomy field)

 

Step 7: Filter Content Using Taxonomy

  1. In the view, click Add under Filter criteria
  2. Choose Content: Category (Taxonomy term)
  3. Configure filter:
    • Operator: Is one of
    • Select terms (e.g., News)
  4. Apply

Now the view will show only content from the selected category.

 

Step 8: Contextual Filter (Dynamic Category Pages)

Contextual filters allow dynamic filtering based on URL.

Example: URL-based category page

  1. Add Contextual filter → Content: Category
  2. When filter value is NOT available: Display all results
  3. When filter value IS available: Filter by taxonomy term ID
  4. Save

Now URL like:

/articles/news

can dynamically load category-specific content.

 

Step 9: Taxonomy Relationships in Views

Sometimes taxonomy fields are not directly available.

  1. In Views, click Advanced → Relationships → Add
  2. Add Content: Category relationship
  3. Use taxonomy fields like Term name, Term ID, etc.

 

Step 10: Use Taxonomy for Menus and Blocks

Category Menu

  • Create a View showing taxonomy terms
  • Display as a block
  • Place it in sidebar

Filter Block

  • Use Exposed filters in Views
  • Allow users to filter content by category

 

Benefits of Using Taxonomy with Views

  • Structured content organization
  • Easy filtering and sorting
  • SEO-friendly URLs
  • Dynamic category pages
  • Reusable content listings

 

Best Practices

  • Use separate vocabularies for different purposes
  • Do not overload a single vocabulary
  • Use machine names carefully
  • Prefer taxonomy over free-text fields
  • Combine taxonomy with Views for scalability

 

Conclusion

Taxonomy and vocabulary are core building blocks of Drupal content architecture. When used correctly with Views, they enable powerful, flexible, and scalable content presentation. Mastering taxonomy will greatly improve your Drupal site structure and user experience.

  • drupal_taxonomy_vocabulary